<?php
/*
* Kusht Mud.
* ----
* The MIT License
* Copyright (c) 2010 Andrew Tutt
* ----
*/

/* Flag Handler
*
* This Function Processes Flag Affects on Commands and state changes
*/

class flagHandler {
	
	/* How to revise the function below:
			Create an array: array(Flag => Code to execute)
			Foreach Flag, check if the User has the flag set
			if so, execute the code, return the result
			if True, stop further command execution
			else let if pass
	*/
	public static function handleCmd($user,$cmd,$phr) {
		// Right now, we'll hardcode it, but it will be easy to revise these to scripts
		if($user->is(FORCED_SLEEP)) {
			if (preg_match("~^".$cmd."~i","stand") || 
				preg_match("~^".$cmd."~i","wake") || 
				preg_match("~^".$cmd."~i","sit") || 
				preg_match("~^".$cmd."~i","rest")) {
				$object->send("You can't wake up!");
				return true;
			}
		}
		
		return false;
	}
	
	// Do a similar check against Flags and Code but now for two users in comparison
	// Return the result to let the state change happen or not. Send output to each of the users
	// and potentially call a host of other built-in functions. Happens when entering/leaving
	// rooms, setting flags, etc.
	public static function handleStateChange($user1,$user2) {
	}
	
	// $user2 is observing $user1
	public static function handleObservation($user1,$user2) {
		
	}
}

?>